home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 October / enter-2005-10.iso / files / jedit42install.exe / {app} / macros / Misc / Display_Character_Code.bsh < prev    next >
Encoding:
Text File  |  2004-08-29  |  812 b   |  29 lines

  1. /**
  2.  * Display int and hex values for the character at 
  3.  * the caret in the status bar.
  4.  *
  5.  * Copyright 2004 Ollie Rutherfurd <oliver@jedit.org>
  6.  *
  7.  * $Id: Display_Character_Code.bsh,v 1.2 2004/05/24 19:24:56 orutherfurd Exp $
  8.  */
  9.  
  10. void displayCharacterCode(View view)
  11. {
  12.     JEditTextArea textArea = view.getTextArea();
  13.     int caret = textArea.getCaretPosition();
  14.     int line = textArea.getCaretLine();
  15.     if(caret < textArea.getLineEndOffset(line)-1)
  16.     {
  17.         char c = buffer.getText(caret,1).charAt(0);
  18.         StringBuffer buf = new StringBuffer();
  19.         buf.append("Character at caret: ");
  20.         buf.append("int=").append((int)c).append(", ");
  21.         buf.append("hex=").append(Integer.toString((int)c,16));
  22.         view.getStatus().setMessageAndClear(buf.toString());
  23.     }
  24.     else
  25.         Toolkit.getDefaultToolkit().beep();
  26. }
  27.  
  28. displayCharacterCode(view);
  29.